
package com.google.code.lebar.bean.response;


import java.util.ArrayList;
import java.util.List;

import com.google.code.lebar.bean.response.action.Action;
import com.google.code.lebar.bean.response.animation.Animation;
import com.google.code.lebar.bean.response.animation.FullAnimation;
import com.google.code.lebar.bean.response.animation.SimpleAnimation;
import com.google.code.lebar.bean.response.dialog.ShownDialog;
import com.google.code.lebar.bean.response.hotspot.Hotspot;


public class LayarResponse implements Cloneable
{
    private String layer;
    private List<Hotspot> hotspots;
    private Integer errorCode;
    private String errorString;
    private String nextPageKey;
    private Boolean morePages;
    private Integer radius;
    private Integer refreshInterval;
    private Integer refreshDistance;
    private Boolean fullRefresh;

    private List<Action> actions;
    private String showMessage;
    private List<Hotspot> deletedHotspots;

    private Animation animations;
    private ShownDialog showDialog;
    private String biwStyle;

    @Override
    public LayarResponse clone()
    {
        LayarResponse tClonedResponse = new LayarResponse();
        tClonedResponse.setLayer( getLayer() );
        tClonedResponse.setHotspots( cloneHotspots() );
        tClonedResponse.setErrorCode( getErrorCode() );
        tClonedResponse.setErrorString( getErrorString() );
        tClonedResponse.setNextPageKey( getNextPageKey() );
        tClonedResponse.setMorePages( getMorePages() );
        tClonedResponse.setRadius( getRadius() );
        tClonedResponse.setRefreshInterval( getRefreshInterval() );
        tClonedResponse.setRefreshDistance( getRefreshDistance() );
        tClonedResponse.setFullRefresh( getFullRefresh() );
        tClonedResponse.setActions( cloneActions() );
        tClonedResponse.setShowMessage( getShowMessage() );
        tClonedResponse.setDeletedHotspots( cloneDeletedHotspots() );
        tClonedResponse.setAnimations( cloneAnimation() );
        tClonedResponse.setShowDialog( getShowDialog() == null ? null : getShowDialog().clone() );
        
        return tClonedResponse;
    }
    
    private Animation cloneAnimation()
    {
        if ( getAnimations() instanceof SimpleAnimation )
        {
            return getAnimations();
        }
        else if ( getAnimations() instanceof FullAnimation )
        {
            return (Animation) ( (FullAnimation) getAnimations() ).clone();
        }

        return null;
    }

    private List<Action> cloneActions()
    {
        if ( getActions() == null ) return null;

        List<Action> tClonedActions = new ArrayList<Action>();
        for ( Action tAction : getActions() )
        {
            tClonedActions.add( tAction.clone() );
        }

        return tClonedActions;
    }

    private List<Hotspot> cloneDeletedHotspots()
    {
        if ( getHotspots() == null ) return null;

        List<Hotspot> tClonedHotspots = new ArrayList<Hotspot>();
        for ( Hotspot tClonedHotspot : getDeletedHotspots() )
        {
            tClonedHotspots.add( tClonedHotspot.clone() );
        }

        return tClonedHotspots;
    }
    
    private List<Hotspot> cloneHotspots()
    {
        if ( getHotspots() == null ) return null;

        List<Hotspot> tClonedHotspots = new ArrayList<Hotspot>();
        for ( Hotspot tClonedHotspot : getHotspots() )
        {
            tClonedHotspots.add( tClonedHotspot.clone() );
        }

        return tClonedHotspots;
    }

    /**
     * @return the layer
     */
    public String getLayer()
    {
        return layer;
    }

    /**
     * @return the hotspots
     */
    public List<Hotspot> getHotspots()
    {
        return hotspots;
    }

    /**
     * @return the errorCode
     */
    public Integer getErrorCode()
    {
        return errorCode;
    }

    /**
     * @return the errorString
     */
    public String getErrorString()
    {
        return errorString;
    }

    /**
     * @return the nextPageKey
     */
    public String getNextPageKey()
    {
        return nextPageKey;
    }

    /**
     * @return the morePages
     */
    public Boolean getMorePages()
    {
        return morePages;
    }

    /**
     * @return the radius
     */
    public Integer getRadius()
    {
        return radius;
    }

    /**
     * @return the refreshInterval
     */
    public Integer getRefreshInterval()
    {
        return refreshInterval;
    }

    /**
     * @return the refreshDistance
     */
    public Integer getRefreshDistance()
    {
        return refreshDistance;
    }

    /**
     * @return the fullRefresh
     */
    public Boolean getFullRefresh()
    {
        return fullRefresh;
    }

    /**
     * @return the actions
     */
    public List<Action> getActions()
    {
        return actions;
    }

    /**
     * @return the showMessage
     */
    public String getShowMessage()
    {
        return showMessage;
    }

    /**
     * @return the deletedHotspots
     */
    public List<Hotspot> getDeletedHotspots()
    {
        return deletedHotspots;
    }

    /**
     * @return the animations
     */
    public Animation getAnimations()
    {
        return animations;
    }

    /**
     * @return the showDialog
     */
    public ShownDialog getShowDialog()
    {
        return showDialog;
    }

    /**
     * @return the biwStyle
     */
    public String getBiwStyle()
    {
        return biwStyle;
    }

    /**
     * @param layer
     *            the layer to set
     */
    public void setLayer( String layer )
    {
        this.layer = layer;
    }

    /**
     * @param hotspots
     *            the hotspots to set
     */
    public void setHotspots( List<Hotspot> hotspots )
    {
        this.hotspots = hotspots;
    }

    /**
     * @param errorCode
     *            the errorCode to set
     */
    public void setErrorCode( Integer errorCode )
    {
        this.errorCode = errorCode;
    }

    /**
     * @param errorString
     *            the errorString to set
     */
    public void setErrorString( String errorString )
    {
        this.errorString = errorString;
    }

    /**
     * @param nextPageKey
     *            the nextPageKey to set
     */
    public void setNextPageKey( String nextPageKey )
    {
        this.nextPageKey = nextPageKey;
    }

    /**
     * @param morePages
     *            the morePages to set
     */
    public void setMorePages( Boolean morePages )
    {
        this.morePages = morePages;
    }

    /**
     * @param radius
     *            the radius to set
     */
    public void setRadius( Integer radius )
    {
        this.radius = radius;
    }

    /**
     * @param refreshInterval
     *            the refreshInterval to set
     */
    public void setRefreshInterval( Integer refreshInterval )
    {
        this.refreshInterval = refreshInterval;
    }

    /**
     * @param refreshDistance
     *            the refreshDistance to set
     */
    public void setRefreshDistance( Integer refreshDistance )
    {
        this.refreshDistance = refreshDistance;
    }

    /**
     * @param fullRefresh
     *            the fullRefresh to set
     */
    public void setFullRefresh( Boolean fullRefresh )
    {
        this.fullRefresh = fullRefresh;
    }

    /**
     * @param actions
     *            the actions to set
     */
    public void setActions( List<Action> actions )
    {
        this.actions = actions;
    }

    /**
     * @param showMessage
     *            the showMessage to set
     */
    public void setShowMessage( String showMessage )
    {
        this.showMessage = showMessage;
    }

    /**
     * @param deletedHotspots
     *            the deletedHotspots to set
     */
    public void setDeletedHotspots( List<Hotspot> deletedHotspots )
    {
        this.deletedHotspots = deletedHotspots;
    }

    /**
     * @param animations
     *            the animations to set
     */
    public void setAnimations( Animation animations )
    {
        this.animations = animations;
    }

    /**
     * @param showDialog
     *            the showDialog to set
     */
    public void setShowDialog( ShownDialog showDialog )
    {
        this.showDialog = showDialog;
    }

    /**
     * @param biwStyle
     *            the biwStyle to set
     */
    public void setBiwStyle( String biwStyle )
    {
        this.biwStyle = biwStyle;
    }
}
